window.onload = function () {
    // 点击文章跳转到详情页

    let avatarRight = document.querySelectorAll('.avatar-right');
    for (let i = 0; i < avatarRight.length; i++) {
        let arid = avatarRight[i].dataset.id;

        // 跳转文章详情页
        avatarRight[i] && avatarRight[i].addEventListener('click', showInfo);
        function showInfo(event) {

            if (event.target.classList.contains('user-title') || event.target.classList.contains('user-text') || event.target.classList.contains('list-pic')) {
                // console.log(11);
                axios.post('/api/articleinfo', { arid })
                    .then(res => {
                        console.log(res)
                        if (res.data.code === 1) {
                            window.location.href = `./articledetails.html?aid=${arid}`;
                        }
                    })
                    .catch(err => {
                        console.error(err);
                    })
            }

        }
    }
}
